package com.sl.au.repository;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.sl.au.entity.EXDEcustomerViewTotal;
import com.sl.au.entity.Option;


public interface ExdeCustomerViewTotalRepository extends JpaRepository<EXDEcustomerViewTotal, String>{
	@Query("select u from EXDEcustomerViewTotal u where 1=1")
	Page<EXDEcustomerViewTotal> getUserList(Pageable pageable);
	//@Query("select u from EXDEcustomerViewTotal u where u.customerName like '%'+?1+'%'")
	@Query("select u from EXDEcustomerViewTotal u where u.saleArea.areaName = ?3 and u.saleArea.superior = ?2 and u.customerName = ?1 and u.business=?4")
	Page<EXDEcustomerViewTotal> getUserList(String namekey,String deptkey,String arearkey,String businkey,Pageable pageable);
	//@Query("select count(u) from EXDEcustomerViewTotal u where u.customerName like '%'+?1+'%' ")
	@Query("select count(u) from EXDEcustomerViewTotal u where u.saleArea.areaName = ?3 and u.saleArea.superior = ?2 and u.customerName = ?1 and u.business=?4 ")
	long getUserCount(String namekey,String deptkey,String arearkey,String businkey);
	@Query("select count(u) from EXDEcustomerViewTotal u where 1=1 ")
	long getUserCount();
	@Query("select count(u) from EXDEcustomerViewTotal u where id=?1 ")
	EXDEcustomerViewTotal findById(String id);
	@Query("select c.superior from SaleArea c group by c.superior ")
	List<Option> getSaleArea();
	
	
}
